import request from '@/utils/request'
import Qs from 'qs'

// 医生相关接口
export const doctorApi = {
  getLoginToken(data) {
    // const params = Qs.stringify(data, { 
    //   encode: false,
    //   indices: false
    // });11111

    // console.log('params:', params);
    // return fasle
    return request({
      url: '/auth/oauth/token',
      method: 'post',
      data: data,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    });
  },
  getLoginConnection(data) {
    return request({
      url: '/upms/connection',
      method: 'post',
      data: data
    })
  },
  login(data) {
    return request({
      url: '/doctor/login',
      method: 'post',
      data: data
    })
  },
  getReports(params) {
    return request({
      url: '/doctor/reports',
      method: 'get',
      params
    })
  },
  getReportDetail(id) {
    return request({
      url: `/doctor/reports/${id}`,
      method: 'get'
    })
  },
  getCaptcha() {
    return request({
      url: '/doctor/captcha',
      method: 'get'
    })
  }
}

// 个人报告相关接口
export const personalApi = {
  getReports(params) {
    return request({
      url: '/personal/reports',
      method: 'get',
      params
    })
  },
  getReportDetail(id) {
    return request({
      url: `/personal/reports/${id}`,
      method: 'get'
    })
  }
}

// 柯桥报告相关接口
export const keqiaoApi = {
  searchByPersonal(data) {
    return request({
      url: '/keqiao/search/personal',
      method: 'post',
      data: data
    })
  },
  searchByNumber(data) {
    return request({
      url: '/keqiao/search/number',
      method: 'post',
      data: data
    })
  },
  getReports(params) {
    return request({
      url: '/keqiao/reports',
      method: 'get',
      params
    })
  },
  getReportDetail(id) {
    return request({
      url: `/keqiao/reports/${id}`,
      method: 'get'
    })
  }
}

// 微信相关接口
export const wxApi = {
  getOpenid(params) {
    return request({
      url: '/wechat/openId',
      method: 'get',
      params
    })
  },
  getToken(data) {
    return request({
      url: '/auth/authentication/openid',
      method: 'post',
      data: data
    })
  },
  getWxUserInfo(params) {
    return request({
      url: '/upms/wechat/report/user/wechat/info',
      method: 'get',
      params,
      headers: {
        'Content-Type': 'application/json'
      }
    })
  },
  getHospitalInfo(params) {
    return request({
      url: '/report/hospital/myHospital',
      method: 'get',
      params
    })
  }
}